package com.nanhai.buddhist.college.module.collegebase.dal.mysql.classes;

import java.util.*;

import com.github.yulichang.wrapper.MPJAbstractLambdaWrapper;
import com.nanhai.buddhist.college.framework.common.pojo.PageResult;
import com.nanhai.buddhist.college.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.mapper.BaseMapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.nanhai.buddhist.college.module.collegebase.api.collegeclass.vo.ClassesInfoDTOPageVO;
import com.nanhai.buddhist.college.module.collegebase.dal.dataobject.classes.ClassesDO;
import com.nanhai.buddhist.college.module.collegebase.dal.dataobject.classes.ClassesTeacherDO;
import org.apache.ibatis.annotations.Mapper;
import com.nanhai.buddhist.college.module.collegebase.controller.admin.classes.vo.*;

/**
 * 班级和教师关联 Mapper
 *
 * @author xqenzo@163.com
 */
@Mapper
public interface ClassesTeacherMapper extends BaseMapperX<ClassesTeacherDO> {

    default PageResult<ClassesTeacherDO> selectPage(ClassesInfoDTOPageVO reqVO) {
        return selectPageForJoin(reqVO,ClassesTeacherDO.class, new MPJLambdaWrapperX<ClassesTeacherDO>() {}
                .eqIfPresent(ClassesTeacherDO::getTeacherId, reqVO.getTeacherId())
                .geIfPresent(ClassesDO::getOpeningTime,reqVO.getOpeningStartTime())
                .leIfPresent(ClassesDO::getOpeningTime,reqVO.getOpeningEndTimeDate())
                .likeIfPresent(ClassesDO::getClassesName, reqVO.getClassesName())
                .eqIfPresent(ClassesDO::getClassesNumber, reqVO.getClassesNumber())
                .eqIfPresent(ClassesDO::getClassesCode, reqVO.getClassesCode())
                .betweenIfPresent(ClassesDO::getOpeningTime, reqVO.getOpeningTime())
                .leftJoin(ClassesDO.class,ClassesDO::getId,ClassesTeacherDO::getClassesId)
                .selectAll(ClassesTeacherDO.class)
                .orderByDesc(ClassesDO::getCreateTime));
    }

}
